package com.significantfiles.snapshot.config;

import java.io.File;

import com.significantfiles.snapshot.engine.rt.x.IllegalConfigException;
import com.significantfiles.snapshot.util.FileUtil;

public class TransactionStorageConfig {

	
	private File dir;
	private int snapshotRange;

	public void setDir(final File dir) throws IllegalConfigException {
	   this.dir = FileUtil.createDir(dir);	
	}
	
	/**
	 * Directory to store transactions.
	 * 
	 * @return
	 */
	public File getDir() {
		return dir;
	}
	
	public void setSnapshotRange(final int snapshotRange) throws IllegalConfigException {
		if (snapshotRange < 0)
			throw new IllegalConfigException(
					"Couldn't initialize TransactionStorage. Number of Transactions before a snapshot is created [snapshot: "
							+ snapshotRange + "]  should be more then 0." );
		
		this.snapshotRange = snapshotRange;
	}
	
	public int getSnapshotRange() {
		return this.snapshotRange;
	}
	
}
